/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.srgsxmldb.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Eldred
 */
public class ContentSwitchServlet extends HttpServlet{
    
    
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)	
            throws IOException {
        
  
        String query = request.getParameter("changeTo");  
        String includeJsp;

        if (query == null || query.isEmpty() || query.equals("/")) {  
            // home - intro  
            includeJsp = "/main";  
        } else {    
        // TODO  
            includeJsp = query; 
        }  

        // draw JSP  
        request.setAttribute("requestedContent", includeJsp);  
        try {  
            request.getRequestDispatcher("/index").include(request, response);  
        } catch (ServletException e) {  
            e.printStackTrace();  
        }  
    }
    
}
